home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / extra_2 / nadir11.zip / WINPUT.N < prev    next >
Text File  |  1995-11-08  |  7KB  |  176 lines

  1. Define TestWinputComboFormat(key, type) {
  2.     if (type != "s")
  3.         return key;
  4.     return key. "\t\t". univ^[key]. "\t";
  5. }
  6. Define TestWinputMandatory(hand, value, name) {
  7.     if (!value) {
  8.         MsgWait("", "Field " . name . " must be entered");
  9.         return 1;
  10.     }
  11. }
  12. Define TestWinput 
  13. /*
  14.     Demonstrate all the widgits in Screen Dialogues
  15. */
  16. {
  17.     scr = SdCreate("Winput", -1, -1, 16, 65, 
  18.                     "Screen Task ". TaskNum(). " at level ". Level());
  19.     var    = "QWERTY";
  20.     vrad   = "y";
  21.     vchk   = "c";
  22.     vsel   = "attn";
  23.     vcom   = "clnt";
  24.     vint   = 889977;
  25.     vfloat = 1234.56;
  26.     vdate  = "14/2/1983";
  27.  
  28.     SdMenu(scr, "main", 1, "Action",    "a", 145,
  29.                         1, "Utilities", "u", 117,
  30.                         1, "Invoice",   "i", 115,
  31.                         1, "Help",      "h", 4);
  32.  
  33.     SdPopup(scr, "inv",  115, 1, "Option a",   "a", 138,
  34.                              1, "Option b",   "b", 139,
  35.                              1, "Option c",   "c", 140);
  36.  
  37.     SdPopup(scr, "optb", 139, 1, "Option ba",  "a", 141,
  38.                              1, "Option bb",  "b", 142);
  39.  
  40. //  SdPopup(scr, "optc", 140, 1, "Option ca",  "a", 143,
  41. //                           1, "Option cb",  "b", 144);
  42.  
  43.     SdPopup(scr, "ute",  117, 1, "Colours",    "c", 125,
  44.                              1, "Printers",   "p", 127);
  45.  
  46.     SdPrompt(scr,            1,  1, "Prompty", "p");
  47.     SdString(scr, "f0",   1, 1,  9, 8, &var, , "caret", "TestWinputMandatory");
  48.     SdPrompt(scr,            2,  1, "Int");
  49.     SdInt   (scr, "int",  1, 2,  9, 8, &vint);
  50.     SdPrompt(scr,            3,  1, "Float");
  51.     SdFloat (scr, "floa", 1, 3,  9, 8, &vfloat, 2);
  52.     SdPrompt(scr,            4,  1, "Date");
  53.     SdDate  (scr, "date", 1, 4,  9, 10, &vdate);
  54.  
  55.     SdButton(scr, "b0",   1, 1, 21, 10, "Disable", "d", 105);
  56.     SdButton(scr, "b1",   1, 2, 21, 10, "Enable", "e", 106);
  57.     SdButton(scr, "ok",   1, 3, 21, 10, "OK", "", 1);
  58.     SdButton(scr, "can",  1, 4, 21, 10, "Cancel", "", 2);
  59.     SdButton(scr, "abr",  1, 5, 21, 10, "Exit", "", 111);
  60.     SdRadio (scr, "r0",   1, 1, 35, 12, &vrad, "Radio x", "x", 107);
  61.     SdRadio (scr, "r1",   1, 2, 35, 12, &vrad, "Radio y", "y", 108);
  62.     SdRadio (scr, "r2",   1, 3, 35, 12, &vrad, "Radio z", "z", 109);
  63.     SdButton(scr, "szc",  1, 5, 31, 10, "SizeChg", "", 112);
  64.     SdCheck (scr, "c0",   1, 1, 50, 12, &vchk, "Check", "c", 110);
  65.     SdCheck (scr, "c1",   1, 2, 50, 15, &repa, "Report Action", "r");
  66.  
  67.     SdCombo (scr, "com",  1, 7,  1, 25, 7, &vcom, "univ^", 134, 
  68.                                        "TestWinputComboFormat", 52,,137);
  69.     SdMultiLine(scr, "ml", 1, 9, 1, 25, 5);
  70.     SdSelect(scr, "sel",  1, 7, 31, 22, 7, &vsel, "univ^ptyp_code^", 
  71.                                         133,,135, 136);
  72.     SdFieldCols(scr, "com", -20, 4, 20);
  73.     SdString(scr, "comv", 1, 15, 1, 50, "");
  74.  
  75.     while ((action = SdEdit(scr, "N"))) {
  76.         if (action == 2 || action == 3)
  77.             break;
  78.         else if (action == 111)
  79.             Exit("Program terminated at users request");
  80.  
  81.         SdUpdate(scr);
  82.  
  83.         switch (action) {
  84.         case 133:
  85.             pre = "(s) - ";         // selected
  86.             goto SH_SELECT;
  87.         case 135:
  88.             pre = "(d) - ";         // double clicked
  89.             goto SH_SELECT;
  90.         case 136:
  91.             pre = "(m) - ";         // moved
  92.         SH_SELECT:
  93.             SdFieldSet(scr, "comv", pre . univ^ptyp_code^[vsel]);
  94.             continue;
  95.         case 134:
  96.             pre = "(s) - ";         // selected
  97.             goto SH_COMBO;
  98.         case 137:
  99.             pre = "(d) - ";         // double clicked
  100.         SH_COMBO:
  101.             SdFieldSet(scr, "comv", pre . univ^[vcom]);
  102.             continue;
  103.         case 138:
  104.             OptionA();
  105.             break;
  106.         case 112:
  107.             sztoggle = sztoggle ? 0 : 1;
  108.             SdPrompt(scr,            1,  1, "Prompt" . (sztoggle ? "" : "y"), "p");
  109.             SdString(scr, "f0",   1, 1,  9, sztoggle ? 10 : 8, &var, , "caret", "TestWinputMandatory");
  110.             SdButton(scr, "ok",   1, 3, 21, sztoggle ? 12 : 10, "OK", "", 1);
  111.             SdButton(scr, "can",  1, 4, 21, sztoggle ? 12 : 10, "Cancel", "", 2);
  112.             SdButton(scr, "szc",  1, 5, 31, sztoggle ? 12 : 10, "SizeChg", "", 112);
  113.             SdCombo (scr, "com",  1, 7,  1, sztoggle ? 20 : 25, 
  114.                                             sztoggle ? 5 : 7, &vcom, 
  115.                                             "univ^", 134, "TestWinputComboFormat", 
  116.                                             52,,137);
  117.             SdSelect(scr, "sel",  1, sztoggle ? 8 : 7, sztoggle ? 35 : 31, 
  118.                                             sztoggle ? 15 : 22, 
  119.                                             sztoggle ? 5 : 7, &vsel, 
  120.                                             "univ^ptyp_code^", 133, , 135, 136);
  121.             SdFieldCols(scr, "com", -20, 4, 20);
  122.             if (sztoggle)
  123.                 SdMultiLine(scr, "ml", 1, 10, 2, 20, 3);
  124.             else
  125.                 SdMultiLine(scr, "ml", 1, 9, 1, 25, 5);
  126.             SdString(scr, "comv", 1, sztoggle ? 14 : 15, 
  127.                                      sztoggle ? 3 : 1, 
  128.                                      sztoggle ? 40 : 50, "");
  129.         }
  130.  
  131.         if (repa)
  132.             MsgWait("NADIR task " . TaskNum(), 
  133.                     "action is " . action .
  134.                     "\nstring is " . var . 
  135.                             (SdFieldMod(scr, "f0") ? " (modified)" : "") .
  136.                     "\nint is " . vint .
  137.                     "\nfloat is " . vfloat .
  138.                     "\ndate is " . vdate .
  139.                     "\nradio is " . vrad .
  140.                     "\ncheck is " . vchk .
  141.                     "\nselect is " . vsel .
  142.                     "\ncombo is " . vcom);
  143.  
  144.         if (action == 105 || action == 106)
  145.             SdModeSet(scr, action == 106, "f0", "b0", "r0", "r1", "r2", "c0");
  146.     }
  147.     SdDestroy(scr);
  148. }
  149. Define OptionA {
  150.     scr = SdCreate(, -2, -2, 14, 60, 
  151.                 "Option A ". TaskNum());
  152.     var = "QWERTY";
  153.     SdPrompt(scr, 1, 2, "Prompty", "p");
  154.     SdString(scr, "f0", 1, 1, 10, 8, &var);
  155.     SdButton(scr, "ok", 1, 3, 20, 8, "OK", "", 1);
  156.     SdButton(scr, "can", 1, 4, 20, 8, "Cancel", "", 2);
  157.     while ((action = SdEdit(scr, "N")) == 1) {
  158.         SdUpdate(scr);
  159.         MsgWait("Option A", "OK button pressed !");
  160.     }
  161.     SdDestroy(scr);
  162. }
  163. Define TestMsgCreate(table) {
  164.     if (!table)
  165.         table = "univ";
  166.     scr = MsgCreate("Test Interruptable Messages - Symbols in ". table);
  167.     while (!abort) {
  168.         code = "";
  169.         while (code = next([table]^[code])) {
  170.             if (abort = MsgShow(scr, "Listing " . code))
  171.                 break;
  172.         }
  173.     }
  174.     MsgDestroy(scr);
  175. }
  176.